<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>User</title>
    <script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <style>
        table {
            font-size: 18px;
            margin: 0 auto;
            text-align: center;
            color: slategray;
        }

        table tr:nth-child(2n) {
            background-color: palegreen;
        }

        h3 {
            text-align: center;
            font-size: 30px;
        }

        #header {
            width: 100%;
            height: 40px;
        }

        #header ul li a {
            padding: 0 20px;
            background-color: #ffff80;
            color: #ff8040;
            font: bold 20px KaiTi;
            border: 1px solid;
            border-radius: 5px;
            text-decoration: none;
            font-size: 30px;
        }

        #header ul li {
            list-style-type: none;
            float: left;
            margin-left: 10px;
        }

        #footer ul li a {
            padding: 0 35px;
            font: bold 20px KaiTi;
            background-color: #ffff80;
            color: #ff8040;
            border: 1px solid;
            border-radius: 5px;
            text-decoration: none;
            font-size: 35px;
        }

        #footer ul li {
            float: left;
            list-style-type: none;
            padding-bottom: 20px;
            margin-left: 80px;

        }

        #footer {
            position: fixed;
            top: 513px;
        }
    </style>
</head>
<body>
<h3>User</h3>
<div id="header">
    <ul>
        <li><a href="add.jsp">新增</a></li>
    </ul>
</div>
<table border="1" width="100%" cellpadding="10" cellspacing="0">
    <tr>
        <th>序号</th>
        <th>编号</th>
        <th>账号</th>
        <th>密码</th>
        <th>名称</th>
        <th>地址</th>
        <th>生日</th>
        <th colspan="3">操作</th>
    </tr>
    <c:forEach items="${requestScope.list}" var="user" varStatus="stat">
        <tr>
            <td>${stat.count}</td>
            <td>${user.id}</td>
            <td>${user.username}</td>
            <td>${user.password}</td>
            <td>${user.name}</td>
            <td>${user.address}</td>
            <td>${user.birthday}</td>
            <td><a href="/UserServlet?way=findById&id=${user.id}">查看</a></td>
            <td><a href="#" onclick="delUser('${user.id}')">删除</a></td>
            <td><a href="/UserServlet?way=findOne&id=${user.id}">修改</a></td>
        </tr>
    </c:forEach>
    <div id="footer">
        <ul>
            <li><a href="/UserServlet?way=findAll&currPageNo=1">首页</a></li>
            <li><a href="/UserServlet?way=findAll&currPageNo=${requestScope.pager.currPageNo-1}">上一页</a></li>
            <li><a href="/UserServlet?way=findAll&currPageNo=${requestScope.pager.currPageNo+1}">下一页</a></li>
            <li><a href="/UserServlet?way=findAll&currPageNo=${requestScope.pager.totalPageCount}">末页</a></li>
        </ul>
    </div>
    <script>
        function delUser(id) {
            alert(id);
            var flag = confirm("你确定要删除这条记录吗？");
            if (flag) {
                alert(id);
                location.href = '/UserServlet?way=delUser&id=' + id;
            }
        }
    </script>
</table>

</body>
</html>
